; **
; * A true simple boot code
; *
; * Author: Renê S. Pinto
; * Date: Apr, 2009
; *
; * To compile:
; *        nasm -f bin -o myboot.bin myboot.asm
; *
; * To test:
; *        qemu -fda myboot.bin -boot a
; *   OR:
; * 
; * Pick up your pendrive, floopy disk, etc:
; * 
; *    sudo dd if=myboot.bin of=/dev/XXX
; *
; * PS1> /dev/XXX should point to your device, perhaps
; *      /dev/fd0 or /dev/sdb 
; * PS2> BEAWARE: All data in your disk will be lost!
; *
; *    Boot with your disk =:)
; *

;
; We are in Real Mode
;
[Bits 16]

;
; Address of video memory
; Each chatacter are represented by 2 bytes:
;
;Byte:      First                      Second
;        -----------|-----------------------------------------
;       |  8 bits   | 1 bit |  3 bits  |   1 bit   |  3 bits  |
;       |-----------|-----------------------------------------|
;       | Character | Blink | BG color | Intensity | FG color |
;        -----------|-----------------------------------------
;
; Fore more information, see:
; http://www.intelligent-systems.info/classes/ee360/game1234/Video%20memory.htm
;
%define VIDEO_MEM 0xB800

;
; BIOS leave us here
;
[ORG 0x7C00]

;
; Setup correct values to segment registers.
;
; This is necessary because some 'bugged' BIOS
; leave us at 0x7C00:0x0000, not in 0x0000:0x7C00,
; that is the same place, but with offset 0.
;
xor ax,ax
mov ds,ax
mov es,ax
mov fs,ax
mov ss,ax

jmp 0x00:start

start:

	mov ax,VIDEO_MEM
	mov es,ax
	mov dx,0x00
	mov di,dx

	mov al,'A'
	mov ah,0x1E  ; Yellow char with blue background, high intensity

	mov [es:di],ax ; Put on the screen =:)

loop:
	jmp loop

;
; Fill unused space
;
times 510-($-$$) db 0x00

;
; Boot signature
;
db 0x55,0xAA

